﻿@{
    ViewBag.Title = "I_InvoiceApplyList";
    Layout = "~/Areas/IM/Views/Shared/_Layout.cshtml";
}
@section Scripts{
    <script type="text/javascript">
        //页面加载       
        $(document).ready(function () {
            DisableBackspace();
            initListcombo();
            bindGrid();
        });
        $(window).resize(function () {
            $.setGridWithSearchBar("#TableForm", "#SearchBar", "#gridApplyList");
        });

        //#region 为Combobox增加--请选择--
        function EUIcombobox(jqS, o) {
            $.ajax({
                type: "POST",
                async: false,
                url: o.url,
                dataType: "JSON",
                success: function (data1, textStatus, jqXHR) {
                    o.data = o.OneOption.concat(data1);
                    delete o.url;
                    delete o.OneOption;
                    $(jqS).combobox(o);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("获取字典数据失败！可能是已经超时，请重新登录！");
                }
            });
        }
        //查询条件下拉框取值
        function initListcombo() {
            //取分中心
            EUIcombobox("#CenterID", {
                url: '@Url.Content("~/Medical/GetCenter/")',
                valueField: 'ID',
                textField: 'Name',
                //prompt: '--请选择--',
                editable: false,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }],
                onSelect: function (rec) {
                    var urlstation = '@Url.Content("~/Medical/GetStation?code=")' + rec.ID;
                    EUIcombobox("#StationID", {
                        url: urlstation,
                        valueField: 'ID',
                        textField: 'Name',
                        //prompt: '--请选择--',
                        editable: false,
                        OneOption: [{
                            ID: "",
                            Name: "--请选择--"
                        }]
                    });
                }
            });
            //#endregion
            //#region 出车分站
            EUIcombobox("#StationID", {
                url: '@Url.Content("~/Medical/GetStation?code=")',
                valueField: 'ID',
                textField: 'Name',
                //prompt: '--请选择--',
                editable: false,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            })

            $('#StartDate').datetimebox('setValue', '@ViewData["start"]');
            $('#EndDate').datetimebox('setValue', '@ViewData["end"]');
        }
        //datagrid加载
        function bindGrid() {
            $("#gridApplyList").datagrid({
                width: 'auto',
                height: 'auto',
                fitColumns: true,
                striped: true,
                singleSelect: false,
                selectOnCheck: true,
                checkOnSelect: true,
                url: '@Url.Content("~/IM/I_InvoiceApply/GetApplyList")',
                loadMsg: '数据加载中请稍后……',
                pagination: true,//启用分页，默认每页10行
                rownumbers: true,//显示页码，默认 提供 10 - 50 的页容量选择下拉框
                pageSize: 15,//设置 页容量5为
                pageList: [10, 15, 20],//设置 页容量下拉框
                queryParams: {
                    StartDate: $("#StartDate").datetimebox("getValue"),
                    EndDate: $("#EndDate").datetimebox("getValue"),
                    CenterID: $("#CenterID").combobox("getValue"),
                    StationID: $("#StationID").combobox("getValue"),
                    State: $("#State").combobox("getValue")
                },
                columns: [
                    [
                   { title: '申请编码', field: 'ApplyID',hidden:true },
                   { title: '分中心编码', field: 'CenterCode',hidden:true },
                   //{ title: '分中心', field: 'Center', width: '5%', sortable: false ,align:"center"}, 不显示分中心
                   { title: '分中心', field: 'Center', hidden: true },
                   { title: "分站编码", field: "StationCode", hidden: true },
                   //{ title: "分站", field: "Station", hidden: true },  显示分站，2017-11-02 周志猛
                   { title: '分站', field: 'Station', width: '5%', sortable: false, align: "center" },
                   { title: "申领人编码", field: "ApplyUserID",hidden:true },
                   { title: "申领人", field: "ApplyPerson", width: '6%', align: "center" },
                   { title: "申领日期", field: "ApplyTime", width: '8%', align: "center" },
                   { title: "领用日期", field: "ReceiveTime", width: '8%', align: "center" },
                   { title: '申领数量', field: 'ApplyCount', width: '5%', align: 'center', sortable: false},
                   { title: '审批人编码', field: 'ApprovalUserID', hidden: true },
                   { title: '审批人', field: 'ApprovalPerson', width: '6%', align: "center" },
                   { title: "审批日期", field: "ApprovalTime", width: '8%', align: "center" },
                   { title: "审批数量", field: "ApprovalCount", width: '5%', align: "center" },
                   { title: "起始号码", field: "StartNumber", width: '10%', align: "center" },
                   { title: "截止号码", field: "EndNumber", width: '10%', align: "center" },
                   { title: "审批状态", field: "ApprovalState", width: '6%', align: "center" },
                   { title: '申领备注', field: 'Remark1', width: '11%', align: "center" },
                   { title: '审批备注', field: 'Remark2', width: '12%', align: "center" }
                    ]
                ],             
                toolbar: [
                    {
                        id: 'btnApplyView',
                        text: '申领发票',
                        iconCls: 'icon-custom-cGoods',
                        iconWidth: 22,
                        handler: function () {
                             initApply();
                             $('#ApplyDetailList').dialog('open');                                                       
                        }
                    }
                ]
            });
          
            $.setGridWithSearchBar("#TableForm", "#SearchBar", "#gridApplyList");
        }
        function reSearch() {
            $("#gridApplyList").datagrid({
                queryParams: {
                    StartDate: $("#StartDate").datetimebox("getValue"),
                    EndDate: $("#EndDate").datetimebox("getValue"),
                    CenterID: $("#CenterID").combobox("getValue"),
                    StationID: $("#StationID").combobox("getValue"),
                    State: $("#State").combobox("getValue")
                }
            });
        }

    </script>
}

<div id="TableForm" class="easyui-layout" style="width:auto; height: auto; margin-left: auto; margin-right: auto">
    <div data-options="region:'center',title:'申领发票详细信息',iconCls:'icon-custom-cApply'">
        <div id="SearchBar" data-options="region:'north'" style="overflow: hidden; padding: 10px">
            <table>
                <tr>
                    <td>申领日期：</td>
                    <td>
                        <input id="StartDate" class="easyui-datetimebox"  style="width:150px" />
                    </td>
                    <td>至：</td>
                    <td>
                        <input id="EndDate" class="easyui-datetimebox" style="width:150px" />
                    </td>
                    <td>分中心：</td>
                    <td>
                        <input id="CenterID" class="easyui-combobox" style="width:150px" data-options="panelHeight:'auto'"/>
                    </td>
                    <td>分站：</td>
                    <td>
                        <input id="StationID" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td>审批状态：</td>                 
                    <td align="right" valign="middle" width="12%">
                        <select class="easyui-combobox" style="width: 150px" id="State" data-options="panelHeight:'auto', editable:false">
                            <option value="-1">--请选择--</option>
                            <option value="0">申请中</option>
                            <option value="1">已审批</option>
                        </select>
                    </td>
                    <td>
                        &nbsp;&nbsp;
                        <a href="javascript:void(0)" id="btnsearch" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reSearch()">查询</a>
                    </td>
                </tr>
            </table>
        </div>
        <div data-options="region:'center'" style="background: #fafafa; overflow: hidden">
            <table id="gridApplyList"></table>
        </div>
    </div>
</div>
@Html.Partial("~/Areas/IM/Views/I_InvoiceApply/I_InvoiceApplyDetail.cshtml")